package com.stars.empoly.fragment

import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.stars.empoly.adapter.HomeSpaceAdapter
import com.stars.empoly.base.MBRFragment
import com.stars.empoly.databinding.FragmentHomeSpaceBinding
import com.stars.empoly.vmodel.HomeSpaceVModel
import com.trailer.base.utils.UiUtils

/**
 * 钓场
 *
 *on 2020/12/5
 */
class HomeSpaceFragment : MBRFragment<HomeSpaceVModel, HomeSpaceAdapter, FragmentHomeSpaceBinding>(){


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        setShow()
    }

    private fun  setShow(){

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { //不支持沉浸式状态栏
        } else {
            //获取状态栏的高度
            val statusBarHeight: Int = UiUtils.getStatusBarHeight()

            //动态设置高度  tv
            val params = binding.tv.getLayoutParams()
            //获取当前控件的布局对象
            //params.height=UiUtils.dp2dip(getContext(), statusBarHeight);//设置当前控件布局的高度
            params.height = statusBarHeight
            binding.tv.layoutParams = params //将设置好的布局参数应用到控件中
            binding.tv.visibility = View.VISIBLE
        }

    }

    override fun vmClass(): Class<HomeSpaceVModel> {
        return HomeSpaceVModel::class.java
    }

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentHomeSpaceBinding {
        return FragmentHomeSpaceBinding.inflate(layoutInflater, container, false)
    }

    override fun initAdapter(): HomeSpaceAdapter {
        return HomeSpaceAdapter(vm)
    }

    override fun title(): String? {
        return null
    }
}
